/*************************************
 * Created by WebStorm
 * Author : 艾尼亚尔·毛拉吾提
 * QQ : 524155792  WeChat : ainiyar0124
 * Created Time :2024/2/5 19:50
 Desc :路由配置
 **************************************/
import type {App} from 'vue';
import { createRouter, createWebHistory } from 'vue-router'
import type {RouteRecordRaw} from 'vue-router';
import routers from './routers.ts';
import {createRouterGuards} from './router_guards.ts';

const Layout = () => import('@/layout/index.vue');

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: routers,
    strict: true,
});
//异常、错误页面
export const ErrorPageRoute: RouteRecordRaw = {
    path: "/:pathMatch(.*)*",
    name: "notFound",
    component: Layout,
    meta: {
        hideInMenu: true,
    },
    children: [
        {
            path: "/:pathMatch(.*)*",
            name: "notFound",
            meta: {
                hideInMenu: true,
                title: "404",
                hideBreadcrumb: true,
            },
            component: () => import("@components/ErrorPage/404.vue"),
        },
    ],
};

export async function  setupRouter(app: App) {
    app.use(router);
    createRouterGuards(router);
}


export default router
